package song.NO_38;

import java.util.ArrayList;

public class CountAndSay {
    private int num;
    private String num_s;
    CountAndSay(){
        this.num = 0;
        this.num_s = "";
    }
    CountAndSay(final int num){
        this.num = num;
        this.num_s = "1";
    }
    public void processing(){
        if (this.num == 1) System.out.println(this.num_s);
        else {
            int i = 2;
            var new_num_s = "";
            while (i != this.num + 1){
                int count = 1; //初始化计数器
                for (int j = 1; j != this.num_s.length(); ++j){
                    if (this.num_s.charAt(j) == this.num_s.charAt(j-1)) ++count;
                    else {
                        var new_num_ss = new StringBuilder(new_num_s);
                        new_num_ss.append(count).append(this.num_s.charAt(j-1));
                        new_num_s = new_num_ss.toString();
//                        new_num_s = new_num_s + Integer.toString(count) + Character.toString(this.num_s.charAt(j-1));
                        count = 1;
                    }
                }
                ++i;
            }
            this.num_s = new_num_s;
        }
    }
    public void print(){
        System.out.println(this.num_s);
    }
    public static void main(String[] args){

    }
}
